package com.zcn.io.web.excel;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.PageReadListener;
import com.zcn.io.common.entity.OrderMain;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;

/**
 * @desc:
 * @author: 202438 邱建伟
 * @date: 2024/9/28 10:28
 * @Copyright (c) 2024, 江苏金恒信息科技股份有限公司
 */
public class BaseListener extends PageReadListener<HashMap<Integer,String>> {

    private final List<Map<Integer,String>> cacheDataList = new ArrayList<>();

    public BaseListener(Consumer consumer) {
        super(consumer);
        System.out.println("触发了");
    }

    public BaseListener(Consumer consumer, int batchCount) {
        super(consumer, batchCount);
    }



    @Override
    public void invoke(HashMap<Integer,String> data, AnalysisContext context) {
        super.invoke(data, context);
        cacheDataList.add(data);
//        DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy.M.d");
//        LocalDate date = LocalDate.parse("20"+ data.get(3), inputFormatter);
//        DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
//        String outPutData = date.format(outputFormatter);
//        System.out.println(outPutData);
    }


    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        super.doAfterAllAnalysed(context);
    }

    public List<Map<Integer, String>> getCacheDataList() {
        return cacheDataList;
    }
}
